package org.dizena.service;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

import org.dizena.entity.User;
import org.dizena.repository.db1mapper.Test1Mapper;
import org.dizena.repository.db1mapper.UserMapper;
import org.dizena.repository.db2mapper.Test2Mapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

@Slf4j
@Service
public class TestService {

    @Resource
    private Test1Mapper test1Mapper;
    @Resource
    private Test2Mapper test2Mapper;
    @Resource
    private UserMapper userMapper;

    @Transactional
    public void add() {
        //test1Mapper.add("1", "admin", "123456");
        //test2Mapper.add(1, 23, "admin");
    }

    public void count() {
        int i1 = test1Mapper.count1();
        int i2 = test2Mapper.count1();
        log.info("i1=" + i1 + "  i2=" + i2);
    }

    public void testSelect() {
        System.out.println(("----- selectAll method test ------"));
        List<User> userList = userMapper.selectList(null);
        Assert.isTrue(5 == userList.size(), "");
        userList.forEach(System.out::println);
    }

}
